package org.dragonnova.meetingserver.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class TimeUtil {

	// 2005 06-12 08:32:33-->date-->long

	/**
	 * current-->String
	 * @return String
	 */
	public static String geTime() {
		Date date = new Date(System.currentTimeMillis());
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy MM-dd HH:mm:ss", Locale.CHINA);
		return dateFormat.format(date);
	}
	/**
	 * long-->String
	 * @param time long型
	 * @return String
	 */
	public static String geTime(Long time) {
		Date date = new Date(time);
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy MM-dd HH:mm:ss",Locale.CHINA);
		return dateFormat.format(date);
	}
	/**
	 * String-->long
	 * @param dateString String类型
	 * @return Long
	 * @throws ParseException
	 */
	public static Long geTime(String dateString) throws ParseException {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy MM-dd HH:mm:ss",Locale.CHINA);
		return dateFormat.parse(dateString).getTime();
	}
}
